// Logger.h: interface for the CLogger class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_LOGGER_H__F1F946FD_36E1_4272_8D37_2A59A4A91AFF__INCLUDED_)
#define AFX_LOGGER_H__F1F946FD_36E1_4272_8D37_2A59A4A91AFF__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <pgl/algotools/STLAlgo.h>
#include <pgl/algotools/Singleton.h>

/*! \brief PGL Core namespace

\ingroup PGLCoreGroup
*/
namespace pgl
{

class CLoggerSingleton;

/*! \brief Logger used by CLoggerSingleton

  \ingroup PGLCoreSingletonGroup
*/
class CLogger  
{
public:
	CLogger();
	virtual ~CLogger();

protected:
	friend class CLoggerSingleton;

	bool IsEnabledP() const						{	return m_bEnabled;};
	void SetEnabledP(bool yes = true)			{	m_bEnabled=yes;};

	void LogP( LPCSTR szFileName, UINT uLine, LPCTSTR szFormat, va_list& list);
	void LogP( LPCSTR szFileName, UINT uLine, const std::_tostream& out); 

	bool m_bEnabled;
	std::_tostringstream m_out;
};

/*! \brief A logger singleton for PGLCore

  \ingroup PGLCoreSingletonGroup
*/
class PGLCORE_EXT_CLASS CLoggerSingleton : public singletons::TSingleton<CLogger, 1>
{
public:
	static bool IsEnabled();
	static void SetEnabled(bool yes = true);
	static void Log( LPCSTR szFileName, UINT uLine, LPCTSTR szFormat, ...);
	static void Log( LPCSTR szFileName, UINT uLine, const std::_tostream& out);
};

};

#endif // !defined(AFX_LOGGER_H__F1F946FD_36E1_4272_8D37_2A59A4A91AFF__INCLUDED_)
